CC          = @CC@
AR          = @AR@
RANLIB      = @RANLIB@
LIBNAME     = @LIBNAME@
srcdir      = @srcdir@
CC_SHL      = @CC_SHL@
SHLIBNAME   = @SHLIBNAME@

INCLUDES    = -I@MPI_INCLUDE_DIR@ -I${srcdir}/../include -I../include -I../../include  -I${srcdir}/../../../../include -I../../../../include
CFLAGS      = @CPPFLAGS@ @CFLAGS@ $(INCLUDES)

top_builddir  = @master_topbuild_dir@
LIBTOOL       = @LIBTOOL@
C_COMPILE       = $(CC) $(DEFS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS)
C_COMPILE_SHL   = $(CC_SHL) $(DEFS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS)

@VPATH@

AD_PVFS2_OBJECTS = ad_pvfs2_close.o ad_pvfs2_read.o \
      ad_pvfs2_open.o ad_pvfs2_write.o \
      ad_pvfs2_fcntl.o \
      ad_pvfs2_flush.o ad_pvfs2_resize.o ad_pvfs2_hints.o \
      ad_pvfs2_delete.o ad_pvfs2.o ad_pvfs2_common.o ad_pvfs2_aio.o \
      ad_pvfs2_read_list_classic.o  ad_pvfs2_io_list.o ad_pvfs2_io_dtype.o \
      ad_pvfs2_write_list_classic.o ad_pvfs2_features.o

default: $(LIBNAME)
	@if [ "@ENABLE_SHLIB@" != "none" ] ; then \
	    $(MAKE) $(SHLIBNAME).la ;\
	fi

.SUFFIXES: $(SUFFIXES) .p .lo

.c.o:
	@if [ "x$(VERBOSE)" != "x1" ] ; then \
	    echo "  CC              $<" ; \
	else \
	    echo $(C_COMPILE) -c $< ; \
	fi
	@$(C_COMPILE) -c $<
.c.lo:
	@if [ "x$(VERBOSE)" != "x1" ] ; then \
	    echo "  CC              $<" ; \
	else \
	    echo $(C_COMPILE_SHL) -c $< -o _s$*.o ; \
	    echo mv -f _s$*.o $*.lo ; \
	fi
	@$(C_COMPILE_SHL) -c $< -o _s$*.o
	@mv -f _s$*.o $*.lo


$(LIBNAME): $(AD_PVFS2_OBJECTS)
	$(AR) $(LIBNAME) $(AD_PVFS2_OBJECTS)
	$(RANLIB) $(LIBNAME) 

AD_PVFS2_LOOBJECTS=$(AD_PVFS2_OBJECTS:.o=.lo)
$(SHLIBNAME).la: $(AD_PVFS2_LOOBJECTS)
	$(AR) $(SHLIBNAME).la $(AD_PVFS2_LOOBJECTS)

coverage:
	-@for file in  ${AD_PVFS2_OBJECTS:.o=.c} ; do \
		gcov -b -f $$file ; done

clean:
	@rm -f *.o *.lo *.gcno *.gcda *.bb *.bbg
	@rm -f ${srcdir}/*.gcno ${srcdir}/*.gcda 
	@rm -f ${srcdir}/*.bb ${srcdir}/*.bbg
